#include <iostream>
#include <boost/asio.hpp>
#include <boost/log/trivial.hpp>
#include "config.hpp"
#include "tcp_listener.hpp"
#include "connection_manager.hpp"

int main(int argc, char* argv[]) {
    if (argc != 2) {
        std::cerr << "Usage: " << argv[0] << " <config_file>" << std::endl;
        return 1;
    }

    try {
        boost::asio::io_context io_context;
        net_channel::server::Config config(argv[1]);
        
        auto listener = std::make_shared<net_channel::server::TcpListener>(
            io_context, config.get_tcp_listener().port);
        listener->start();

        BOOST_LOG_TRIVIAL(info) << "Server started";
        io_context.run();
    } catch (const std::exception& e) {
        BOOST_LOG_TRIVIAL(error) << "Server error: " << e.what();
        return 1;
    }

    return 0;
}